<?php
class Header extends Element{
	
	private $authorizedElements = array("Link","Image","Text");
	
	private $level;
	
	public function __construct($level){
		parent::__construct($this->authorizedElements);
		$this->level = $level;
	}
	
	private function convert_to_anchor($string){
		$search = array(' ', 'é', 'è', 'à', 'ê', 'ï', 'É','ç');
		$replace = array('_','.C3.A9', '.C3.A8', '.C3.A0', '.C3.AA', '.C3.AF', '.C3.89','.C3.A7');
		$string = trim($string);
		return str_replace($search,$replace,$string);
	}
	
	public function __toString(){
		$string = parent::__toString();
		return '<a name="' . $this->convert_to_anchor($string) . '" ></a><h'.$this->level.'>'.$string.'</h'.$this->level.'>';

    }
}
?>